package com.example.mobile2021606140lhq0330;

import android.os.Bundle;
import android.util.Log;
import android.view.DragEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText edtTxtMainAccount;
    private EditText edtTxtMainPsw;
    private Button btnMainLogin;
    private Button btnMainReset;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String strAccount = edtTxtMainAccount.getText().toString();
                String strPsw = edtTxtMainPsw.getText().toString();

                //不完整判断
                if (strAccount.length()==0){
                    Log.i("登录","用户名不能为空");
                }else
                    if (strPsw.length()==0){
                        Log.i("登录","密码错误");
                    }else {
                        if (strAccount.equals("admin") & strPsw.equals("123456")) {
                            Log.i("登录", "登录成功");
                        } else {
                            Log.i("登录", "登录失败");
                        }
                        edtTxtMainAccount.setText(null);
                        edtTxtMainPsw.setText(null);

                    }

            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        edtTxtMainAccount = (EditText) findViewById(R.id.edtTxt_main_account);
        edtTxtMainPsw = (EditText) findViewById(R.id.edtTxt_main_psw);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainReset = (Button) findViewById(R.id.btn_main_reset);
    }
}